<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="websql.Query"%>
<%@page import="unit.EscapeUnescape"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>


<script type="text/javascript">
var xmlHttp;
var requestType = "";
//创建XMLHttpRequest对象
function GetXmlHttpObject() {
	var xmlHttp;
	 try
	    {
	   // Firefox, Opera 8.0+, Safari
	    xmlHttp=new XMLHttpRequest();
	    }
	 catch (e)
	    {
	  // Internet Explorer
	   try
	      {
	      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	      }
	   catch (e)
	      {
	      try
	         {
	         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	         }
	      catch (e)
	         {
	         alert("您的浏览器不支持AJAX！");
	         return false;
	         }
	      }
	    }
	    return xmlHttp;
	}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("vtab").innerHTML=xmlHttp.responseText;
 } 
}



function showvar()
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	 {
	 alert ("您的浏览器不支持AJAX！");
	 return
	 }
	var url="getvarinfo.jsp";
	url=url+"?qid="+document.getElementById("qid").value;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged ;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}

</script>



</head>
<body>

<%
	request.setCharacterEncoding("UTF-8");
%>

<form action="query_action.jsp" method="post">
<table>
	<tr>
		<td>选择</td>
		<td><select name=qid id="qid" onchange="showvar()">
			<option value="">请选择查询项目</option>
			<%
				String qname[] = websql.Query.getQueryNames();
				for (int i = 0; i < qname.length; i++) {
					out.print("<option value =\""
							+ Query
									.getqid("qname", EscapeUnescape
											.escape(qname[i])) + "\">" + qname[i]
							+ "</option>");
				}
			%>
		</select></td>
	</tr>
	<tr>
		<td colspan=2>
		<div id=vtab></div>
		</td>
	</tr>
	<tr>
		<td><input type="submit" value="查询"></input></td>
		<td><input type="reset" value="重置"></input></td>
	</tr>
</table>

</form>
</body>
</html>